package com.luomuchen.demo02.controller;

import com.luomuchen.demo02.servic.OopService;
import org.apache.ibatis.ognl.ObjectElementsAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@RestController
public class OopController {
    @Autowired
    private OopService oopService;
    @GetMapping("/get/{id}")
    public Object get(@PathVariable("id") Integer id){
        ExecutorService es = Executors.newFixedThreadPool(500);
        for (int i = 0; i < 500; i++) {
            es.submit(new Runnable() {
                @Override
                public void run() {
                    oopService.getOopById(id);
                }
            });
        }
        return oopService.getOopById(id);
    }
}
